<?php
declare(strict_types=1);
namespace app\index\controller;

use app\Request;
use think\facade\Db;

class Index
{
    public function index()
    {
        $res = Db::name("test")->select();
        $index = 8;

        return view('index',['res'=>$res]);
    }

    public function test(Request $request){
        $res = Db::name("test")->insert($request->all());
        if(isset($res)){
            return json(['code'=>0,"msg"=>"添加成功"]);
//            return json_encode(['code'=>0,"msg"=>"添加成功"],JSON_UNESCAPED_UNICODE);
        }else{
            return json(['code'=>0,"msg"=>"添加失败"]);
//            return json_encode(['code'=>0,"msg"=>"添加失败"],JSON_UNESCAPED_UNICODE);
        }
//        return json_encode($request->all(),JSON_UNESCAPED_UNICODE);
    }

    public function hello(){
        echo "hello";
    }
}
